home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / arexx / rexxbgui / testlistview.rexx < prev    next >
OS/2 REXX Batch file  |  1999-06-14  |  3KB  |  100 lines

  1. /* REXX script for rexxbgui.library: test new listview functions */
  2.  
  3. if ~show('l','rexxbgui.library') then do
  4.     if ~addlib('rexxbgui.library',0,-30) then do
  5.         exit(20)
  6.     end
  7.     else nop
  8. end
  9. else nop
  10.  
  11. call bguiopen() /* causes error 12 if it did not work */
  12. /* supply a second argument for a '0' return code instead of an ARexx
  13.    error */
  14.  
  15. signal on syntax /* important: bguiclose() MUST be called */
  16. signal on halt
  17. signal on break_c
  18.  
  19. esc='1B'x
  20. lf='0A'x
  21. cr='0D'x
  22. grspace.narrow=-1
  23. grspace.normal=-2
  24. grspace.wide=-3
  25. FixMinSize=bguilayout(LGO_FixMinWidth,1,LGO_FixMinHeight,1)
  26.  
  27. /* using ARexx feature: ,<newline> is translated to nothing */
  28. /* the || are essential - any added space will cause trouble */
  29. /* redefining the same ID makes previous buttons unaccessible */
  30. /* do not redefine winclose etc. */
  31.  
  32. g=bguivgroup(,
  33.     bguivgroup(,
  34.         bguilistview('listv',,bguilist('it','Item 1','Item 2'),'D')||,
  35.         bguihgroup(,
  36.             bguibutton('add','_Add')||,
  37.             bguibutton('rem','_Remove')||,
  38.             bguibutton('sort','_Sort'),
  39.         ,0,,,'W')||bguilayout(LGO_FixMinHeight,1)||,
  40.         bguistring('str',,'New Item',80)||bguilayout(LGO_FixMinHeight,1),
  41.     ,0)||,
  42.     bguihgroup(,
  43.         bguivarspace(50)||,
  44.         bguibutton('quit','_Quit')||,
  45.         bguivarspace(50),
  46.     )||bguilayout(LGO_FixMinHeight,1),
  47. ,grspace.normal,grspace.normal)
  48.  
  49. drop it.
  50.  
  51. call bguiset(obj.rem,,GA_Disabled,1)
  52. call bguiaddmap(obj.listv,obj.str,LISTV_Entry,STRINGA_TextVal)
  53.  
  54. a=bguiwindow('Listview',g,40,70,,arg(1))
  55.  
  56. if bguiwinopen(a)=0 then bguierror(12)
  57. id=0
  58. do while bguiwinwaitevent(a,'ID')~=id.winclose
  59.     select
  60.         when id=id.str then do
  61.             call bguilistvreplacesel(obj.listv,a,,
  62.                 bguiget(obj.str,STRINGA_TextVal))
  63.             call bguiset(obj.rem,a,GA_Disabled,0)
  64.         end
  65.         when id=id.add then do
  66.             call bguilistvaddentry(obj.listv,a,,
  67.                 '<new>',,'S')
  68.             call bguiset(obj.rem,a,GA_Disabled,0)
  69.             call bguiset(obj.str,a,STRINGA_TextVal,'')
  70.             call bguiactivategadget(obj.str,a)
  71.         end
  72.         when id=id.listv then do
  73.             call bguiset(obj.rem,a,GA_Disabled,0)
  74.         end
  75.         when id=id.rem then do
  76.             call bguilistvcommand(obj.listv,a,'remselected')
  77.             if bguiget(obj.listv,'LISTV_NumEntries')=0 then,
  78.             call bguiset(obj.rem,a,GA_Disabled,1)
  79.         end
  80.         when id=id.sort then call bguilistvcommand(obj.listv,a,'sort')
  81.         when id=id.winactive then nop
  82.         when id=id.wininactive then nop
  83.         when id=id.quit then leave
  84.         when id=id.winclose then nop
  85.         otherwise nop
  86.     end
  87. end
  88. rc=0
  89.  
  90. syntax:
  91. if rc~=0 then say '+++ ['rc']' errortext(rc) 'at line' sigl
  92. call bguiclose()
  93. exit 0
  94.  
  95. break_c:
  96. halt:
  97. rc=0
  98. say '+++ Break at line' sigl
  99. signal syntax
  100.